package com.lolo.json.restlet;

import java.util.ArrayList;
import java.util.List;

public class JsonMetaData {
	
	public static class Action {
		public static final String[] EMPTY = {};
		private String name;
		private String description;
		private String[] parameters;
		public Action(String name, String[] parameters) {
			this.name = name;
			this.parameters = parameters;
		}
		public void setDescription(String description) {
			this.description = description;
		}
		public String getName() {
			return name;
		}
		public String[] getParameters() {
			return parameters;
		}
	}

	private String version;
	private String serviceName;
	private String description;
	public List<JsonMetaData.Action> actions = new ArrayList<JsonMetaData.Action>();

	public JsonMetaData(String version, String serviceName) {
		this.version = version;
		this.serviceName = serviceName;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	public Action addAction(String name, String... parameters) {
		if (parameters == null) {
			return this.addAction(name);
		} else {
			JsonMetaData.Action action = new JsonMetaData.Action(name, parameters);
			this.actions.add(action);
			return action;
		}
	}
	public Action addAction(String name) {
		JsonMetaData.Action action = new JsonMetaData.Action(name, JsonMetaData.Action.EMPTY);
		this.actions.add(action);
		return action;
	}
	public String getVersion() {
		return version;
	}
	public String getServiceName() {
		return serviceName;
	}
}
